package com.gzl.demo.controller;

import com.gzl.demo.utils.CalendarUtil;
import redis.clients.jedis.Jedis;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 *
 * </p>
 *
 * @author gzl
 * @since 2021/6/4
 */
public class Aaa{



    public static void main(String[] args) {

        int a=3;
        int b=4;
        int c=5;
        int d = 10;
        int e = 12;
        int bb = 16;
        int f = 13;

        Runnable runnable = new Runnable() {
            @Override
            public void run() {

            }
        };

        CountDownLatch countDownLatch =new CountDownLatch(10);
        ExecutorService executorService = Executors.newFixedThreadPool(10);
       /* LocalDateTime localDateTime = LocalDateTime.now();
        LocalDateTime LocalDateTimeMax = CalendarUtil.specifyDateByMax(localDateTime);

        Long expire = CalendarUtil.tiemDifference(localDateTime, LocalDateTimeMax);
        System.out.println(expire);*/
        /*com.gzl.demo.entity.Aaa aaa = new com.gzl.demo.entity.Aaa();
        //aaa.setName(null);

        com.gzl.demo.entity.Aaa bbb = new com.gzl.demo.entity.Aaa();
        com.gzl.demo.entity.Aaa ccc = new com.gzl.demo.entity.Aaa();
        ccc.setName("hahha");

        List<com.gzl.demo.entity.Aaa> list = new ArrayList<>();
        list.add(aaa);
        list.add(bbb);
        list.add(ccc);
        List<String> collect = list.stream().map(com.gzl.demo.entity.Aaa::getName).collect(Collectors.toList());
        *//*HashSet set = new HashSet(collect);
        collect.clear();
        // 将去重后的元素重新添加到list中
        collect.addAll(set);*//*
        for (String s : collect) {
            if (s==null){
                System.out.println("为null");
            }else {
                System.out.println(s);
            }

        }*/

       /* Map<String, Integer> map = new HashMap<>();
        map.put("aa", 1);
        System.out.println(map.get("aa"));
*/

/*
        String startTime = LocalDate.now() + " 09:00";
        String endTime = LocalDate.now() + " 11:00";
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        LocalDateTime begin = LocalDateTime.parse(startTime, formatter);
        LocalDateTime end = LocalDateTime.parse(endTime, formatter);

        if (LocalDateTime.now().isAfter(begin) && LocalDateTime.now().isBefore(end)){
            System.out.println("hahahha");
        }else {
            System.out.println("hehehh");
        }*/

        //String createTime = waiterOrderListItem.getString("CreateTime");
        /*String createTime ="2021-12-21 12:11:11";
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy/M/d H:m:s");
        DateTimeFormatter dd = DateTimeFormatter.ofPattern("yyyy-M-d H:m:s");
        LocalDateTime orderCreate;
        try {
            orderCreate = LocalDateTime.parse(createTime, df);
        }catch (Exception e){
           e.printStackTrace();
            orderCreate = LocalDateTime.parse(createTime, dd);
        }
        System.out.println(orderCreate);*/

        /*long toSeconds = TimeUnit.MINUTES.toSeconds(60);
        System.out.println(toSeconds);*/
        //long time = new Date().getTime();
        //System.out.println(time);
        //System.out.println(System.currentTimeMillis());



        /*Runnable runnable = new Runnable() {
            @Override
            public void run() {

            }
        }
*/


            //连接本地的 Redis 服务
            Jedis jedis = new Jedis("localhost");
            // 如果 Redis 服务设置了密码，需要下面这行，没有就不需要
            // jedis.auth("123456");
            System.out.println("连接成功");
            //查看服务是否运行
            System.out.println("服务正在运行: "+jedis.ping());
            jedis.set("aa","bb");
            jedis.set("aa","cc");
        System.out.println(new Date());

        jedis.append("aa", "dd");
        //jedis.set("num", "10");
        //jedis.decrBy("num", 5);
        //jedis.decr("num");
        //jedis.psetex("age",10000,"15");

        /*SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); //设置格式
        String day = format.format(new Date());
        String ss = "IntegralSign_executeStartIssuingCoupons:_marketingProgramId: " + "154512" + "_userId:" + "1564616513" + "_companyId:" + "15515" + "_programId:" + "156546" + "_sourceType:" + "156165" + "_programGiftId:" + "1654615" + "_num" + 2 + "_day";
        String crypt = crypt(ss);
        System.out.println(crypt);*/
        //b657ca5caa72fc6230abd28162747e20
        //0d44196fd5c71078ce708d62f31121d3
        //b710e970a146cdd083c7e209d5db6b3a




        int dayOfWeek = CalendarUtil.getDayOfWeek();
        int i = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
        System.out.println(i);
        com.gzl.demo.entity.Aaa aaa =new com.gzl.demo.entity.Aaa();

        System.out.println(aaa.getAge());

        long ba = TimeUnit.SECONDS.toSeconds(1);
        System.out.println(ba);
    }

    public static String crypt(String str) {
        if (str == null || str.length() == 0) {
            throw new IllegalArgumentException("String to encript cannot be null or zero length");
        }
        StringBuffer hexString = new StringBuffer();
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(str.getBytes());
            byte[] hash = md.digest();
            for (int i = 0; i < hash.length; i++) {
                if ((0xff & hash[i]) < 0x10) {
                    hexString.append("0" + Integer.toHexString((0xFF & hash[i])));
                } else {
                    hexString.append(Integer.toHexString(0xFF & hash[i]));
                }
            }
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

        
        return hexString.toString();
    }
}
